package com.demo.web;

import com.demo.entity.CustomCrud;
import com.demo.server.IndexServer;
import com.jweb.annotaion.JAutowired;
import com.jweb.annotaion.JController;
import com.jweb.annotaion.JParam;
import com.jweb.core.handle.Controller;

@JController("/callback")
public class CallBackController extends Controller {

	@JAutowired
	private IndexServer server;

	public static void main(String[] args) {
		try {
			CustomCrud ps = CustomCrud.class.newInstance();
			System.out.println(ps.getId());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void add() {
		try {
			System.out.println("add1=" + request.get().getParameter("p"));
			Thread.sleep(10000);
			System.out.println("add1=" + request.get().getParameter("p"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		toWriterText("");
	}

	public void add2() {
		try {
			System.out.println("add2=" + request.get().getParameter("p"));
			Thread.sleep(10000);
			System.out.println("add2=" + request.get().getParameter("p"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		toWriterText("");
	}

	public void CallBackManager(@JParam("{1}") String msg) {
		System.out.println(getParameterURL().toString());
		toWriterText(msg);
	}

	public void p2p() {
		toWriterText("{\"body\":{\"rtn_code\":\"00\"}}");
	}
}
